#if !defined(MQTT_MYCHANNEL_INCLUDE_H)
#define MQTT_MYCHANNEL_INCLUDE_H
#pragma once

#include "DrvFrame.h"
#include "ZObjectPool.h"
#include "MyQuery.h"
#include "MyResponse.h"

typedef std::list<TSLIEvent*>CEventList;

class CMyConfig;
class CMyServer;
class CMyChannel : public CBaseDsChannel  
{
public:
	CMyChannel(IDsChannel* pIChannel);
	virtual ~CMyChannel();
	
	virtual bool OnInitialize();
	virtual void OnTagSort(int& nFirstKey, int& nSecondKey, int& nThirdKey);
	virtual void OnTagToPackage(IDsPackage* pIPackage, IDsTag* pTag);
	virtual void OnScanPackageBeforeStart(IDsPackage* pIPackage);
	virtual bool OnStart();
	virtual bool OnStop();	
	virtual bool OnDisconnect();
	virtual void OnScan(int nConnectStatus = 1,int nRsvData = 0);
	virtual int OnIoWriteReturn(TIO_WRITEDATA* pIoWriteResult, IDsTag* pTag);
	virtual int OnRecievedResponse(CSTNBuffer& oBufferRev, IDsPackage* pPackQuery);
	virtual int OnEventOccur(int nType, void* pIEvent, IDsTag* pTag);
	virtual int OnRTDbNotified(TSYM_VALUENOTIFIED* pValue, IDsTag* pTag);

private:
	void _LoopLoadIDb(ISLDbGroup* pIGroup,CMyNode* pNode);
	void _CreateDsTags();
	void _MakeZValue(CMyTag* pMyTag);

public:
	ISLApp*	m_pIApp;
	ISLDbGroup*		m_pIDb;
	CMyConfig*	m_pMyConfig;
	CMyResponse m_oResponsed;
	CMyQuery m_oQuery;
	CZObjectPool*	m_pZPoolRecv;
	CMyServer*	m_pMyServer;

	int m_nTrace;
	std::string m_csDriverPath;
	std::string  m_csTempRTDatas;

	CMyNode*	m_pDbRoot;
	CMyNodeList	m_lstAllNodes;
	CMyTagList	m_lstAllTags;


public:
	CEventList	m_lstEvent;
};

#endif // !defined(MQTT_MYCHANNEL_INCLUDE_H)
